fix(verify): reject non-ed25519 signing keys (closes #52)#8
Open
akuraposo wants to merge 1 commit into
Open
Conversation
The local reference verifier only checks the receipt's `signatureAlg` label, but `resolvePublicKey` accepts any SPKI public key. Node's `crypto.verify(null, ...)` accepts RSA, ECDSA, and Ed448 signatures through the same call path, so a receipt signed with another algorithm can pass verification as an Ed25519 receipt. This patch adds an `asymmetricKeyType === 'ed25519'` check inside `asPublicKey` so every key loaded from a file or remote discovery endpoint is rejected up front if it is not an Ed25519 public key. Closes #52 - Updated `keyResolver.ts` to fail closed on non-ed25519 keys - Added regression tests for RSA and ECDSA P-256 keys - All 7 existing tests still pass
Author
|
FYI: I've opened a separate issue with a full bypass POC for the #36 challenge, demonstrating the algorithm-confusion flaw this PR fixes: permission-protocol/deploy-gate#58 The POC forges an Authority Receipt that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #52: the local reference verifier in
pp-cliwas accepting signaturesmade with non-Ed25519 keys while reporting
signatureAlg: "ed25519"asverified. This allowed algorithm/key-type confusion attacks — a receipt
signed with RSA, ECDSA, or Ed448 could pass verification as an Ed25519
receipt whenever the resolved key record matched
signatureKeyId.Affected code
src/keyResolver.tsparsed PEM or DER public keys without checkingKeyObject.asymmetricKeyType. Node'sverify(null, ...)accepts RSA,ECDSA, and Ed448 signatures through that same call path, so the only
gate was the receipt's
signatureAlglabel, not the actual key.Fix
asPublicKey()now requiresasymmetricKeyType === 'ed25519'and throwsa
KEY_RESOLUTION_FAILED-shaped error for any other key type. The checkis applied in the shared key-loading path so both remote discovery and
offline key files fail closed.
Reproduction (before the fix)
tests/fixtures/valid.json).signatureAlg: "ed25519"unchanged.signatureKeyIdto a matching RSA key record and sign thecanonical bytes with the RSA private key.
data:key URL and callverifyReceipt().Observed before the fix:
verified: true(the receipt is reported asEd25519-verified even though it was signed with RSA).
I also reproduced successful verification with generated ECDSA P-256
and Ed448 key pairs. The patch fails closed for every parsed public key
whose
asymmetricKeyTypeis noted25519.Validation
npm test -- --run— all 7 tests pass (5 pre-existing + 2 newregression tests for RSA and ECDSA P-256 keys)
npm run build— cleangit diff --check— cleanBounty
Submitted for assessment under #36 as a distinct Ed25519
verification-flow flaw. Payout details can be provided privately after
validation.